<template>  
  <view class="container" :modelValue="formData"> 
	<view  >
        <uni-forms ref="baseForm" > 
			<uni-forms-item label="期号:" >
				<uni-easyinput  v-model="formData.lotteryNo"   type="number" maxlength="5"/>
			</uni-forms-item>  
			<uni-forms-item label="彩种:">  
				<picker class="picker-box" mode="selector" :range="lotteryType" @change="selectLetteryType">  
				  <view class="picker">  
					{{lottery}}  
				  </view>  
				</picker>  
			</uni-forms-item>  
			<uni-forms-item label="项目名称:" >  
				  <uni-easyinput v-model="projectName"  :inputBorder="true" >
					 <button slot="right"  size="mini"  @click="openProjectName">选择项目</button>
					</uni-easyinput>
			</uni-forms-item> 
			<uni-forms-item label="号码:" v-show="numbers">
			   <uni-easyinput    v-model="formData.numbers"   :maxlength="numLength">
				   <button slot="right"  size="mini"  @click="optionResult">计算</button>
				</uni-easyinput>
			</uni-forms-item>
			<uni-forms-item  :label="HTU" v-show="contentH">  
				<scroll-view class="scroll-container" scroll-x="true" style="white-space: nowrap;">
					<view class="demo-uni-row1"  v-show="contentH" >  
						<uni-data-checkbox v-model="hundred" @change="clearResult" :localdata="hobbies" mode="tag" multiple  />  
					</view>
				</scroll-view>
			</uni-forms-item>
			<uni-forms-item  label="十位:" v-show="contentT"> 
				<scroll-view class="scroll-container" scroll-x="true" style="white-space: nowrap;">
					<view class="demo-uni-row1"  v-show="contentT">
						<uni-data-checkbox v-model="ten" @change="clearResult" :localdata="hobbies" mode="tag" multiple  />  
					</view> 
				</scroll-view>
			</uni-forms-item>
			<uni-forms-item  label="个位:" v-show="contentU"> 
				<scroll-view class="scroll-container" scroll-x="true" style="white-space: nowrap;">
					<view class="demo-uni-row1"  v-show="contentU">
						<uni-data-checkbox v-model="theUnit" @change="clearResult" :localdata="hobbies" mode="tag" multiple  />  
					</view>  
				</scroll-view>
          </uni-forms-item> 
		  <uni-forms-item label="内容:" v-show="resultContent">
		  		<textarea  disabled style="background-color: white; border-radius: 10px;width: 100%;"
				 v-model="formData.result.join(' ')" :maxlength="textareaMaxlength" ></textarea>
		  <text >{{formData.result.length}}/{{textareaMaxlength ==0 ? 0 : textareaMaxlength/4}}</text><!-- {{textareaMaxlength/4 -->
				<view>
					<uni-row :gutter="10"  class="row-conter">
					  <uni-col :span="6">  
					    <button size="mini" @click="clear">清空</button>  
					  </uni-col>
					  <uni-col  :span="6" v-if="pasteButton">
					    <button size="mini" @click="paste">粘贴</button>  
					  </uni-col> 
					  <uni-col  :span="6" v-show="optionButton" >
					    <button size="mini" @click="optionResult()">计算</button>  
					  </uni-col>
					</uni-row> 
				</view>
		  </uni-forms-item>
       <!--   <uni-forms-item label="佣金:" class="commission-option">  
			 <uni-easyinput :styles="styles"   v-model="formData.commission" disabled="" placeholder="请输入姓名" /></uni-forms-item>
		  </uni-forms-item>  
		  <uni-forms-item   label="" style="padding-left: 20%;">
				<uni-data-checkbox selected-color="#742305" v-model="formData.status" :localdata="statusData" />
		  </uni-forms-item>  -->
        </uni-forms>  
   </view>
    <uni-row>  
      <uni-col>  
        <button class="submit-button" @click="copyData">复制</button>  
      </uni-col>  
    </uni-row> 
	 <view>
		 <uni-popup ref="alertDialog" background-color="#fff" type="bottom">
		 		<uni-row class="demo-uni-row" style="margin-bottom: 15px" :gutter="26" v-for="(item, index) in projectNames">
		 			<uni-col :span="8" v-for="(val, i) in item.projectName" :key="i">
		 				<button style="font-size: 10px	;" class="buttonNoActive01" @click="selectProjectName(val.name, val.id,val.amount)" >
		 					<text class="buttontext">{{ val.name }}</text>
		 				</button>
		 			</uni-col>
		 		</uni-row>
		 </uni-popup>
	 </view>
  </view>  
</template>  

<script>  
export default {  
  data() {  
    const options = Array.from({ length: 10 }, (_, i) => ({ text: `${i}`, value: i }));  
    return { 
		optionButton:false,
		pasteButton:false,
		textareaMaxlength: 1000 *4,
		content:false,
		resultContent:true,
		numbers: true,
		numLength:5,
		contentH:false,
		contentT:false,
		contentU:false,
		HTU:"百位",
      projectNames: [
		{
			projectName:[{name:"大底700+",id:"1",amount:"6.6"},{name:"五码胆出123",id:"11",amount:"6.6",amount:"6.6"},{name:"百十差排除3个号码",id:"21",amount:"6.6"},]
		},
		{
			projectName:[{name:"大底600+",id:"2",amount:"8.8"},{name:"四码胆出123",id:"12",amount:"8.8"},{name:"百个差排除3个号码",id:"22",amount:"6.6"},]
		},
		{
			projectName:[{name:"大底500+",id:"3",amount:"9.9"},{name:"三码胆出123",id:"13",amount:"9.9"},{name:"十个差排除3个号码",id:"23",amount:"6.6"},]
		},
		{
			projectName:[{name:"大底400+",id:"4",amount:"12.8"},{name:"任意7码出23",id:"14",amount:"16.8"},{name:"百十和排除3个号码",id:"24",amount:"6.6"},]
		},
		{
			projectName:[{name:"大底300+",id:"5",amount:"16.8"},{name:"百位排除3码",id:"15",amount:"6.6"},{name:"百个和排除3个号码",id:"25",amount:"6.6"},]
		},
		{
			projectName:[{name:"大底200+",id:"6",amount:"33"},{name:"十位排除3码",id:"16",amount:"6.6"},{name:"十个和排除3个号码",id:"26",amount:"6.6"},]
		},
		{
			projectName:[{name:"大底100+",id:"7",amount:"66"},{name:"个位排除3码",id:"17",amount:"6.6"},{name:"任意选3个差",id:"27",amount:"16.8"},]
		},
		{
			projectName:[{name:"精选50注",id:"8",amount:"128"},{name:"排除3个和尾",id:"18",amount:"6.6"},{name:"任意选3个和",id:"28",amount:"16.8"},]
		},
		{
			projectName:[{name:"精选10注",id:"9",amount:"198"},{name:"排除6个两码",id:"19",amount:"6.6"},{name:"百十个排除2x2x2",id:"29",amount:"9.9"},]
		},
		{
			projectName:[{name:"排除任意2个号码",id:"20",amount:"9.9"}]
		}
	  ],
      projectName: '五码胆出123',
      lotteryType: ['排三推荐','3D推荐'], 
      lottery: '排三推荐',
      hundred: options.map(o => o.value),  
      ten: options.map(o => o.value),  
      theUnit: options.map(o => o.value),  
      hobbies: options,  
      combinations1: [],  
      combinations2: [],  
      combinations3: [], 
	  type:"plw",
	  formData:{
		  lotteryNo:0,// 期号
		  commission:'9.9', // 佣金
		  numbers:"", // 号码
		  projectNameIndex:"11",// 项目名称的索引
		  lotteryTypeIndex:0,// 彩票类型索引
		  result:[],
		  status:1 // 1免费 0不中返还
	  },
	  statusData:[
		  {
			text: '不中返还',
			value: 0
		}, {
			text: '免费',
			value: 1
		} 
	  ],
	  lotteryRes:""
    };  
  },
  onShow() {
	  // 加载彩票期数
		//this.getLastLotteryNo()
  },
  onLoad(query) {
  	// 解析参数中的spliceAll数组
  		let data = JSON.parse(query.item);
		this.showData(data);
	},
  methods: {
	  showData(data){
		  let harr = ["1","2","3","4","5","6","7","8","9"] // 这是 700 到 10 注打底
			harr = harr.map(Number);
		  let arr = ["11","12","13","14","15","16","17","18","19","20","27","28"] // 这是 5 4 3 码胆出选项
		  arr = arr.map(Number);
		  let optionResultArr = ["21","22","23","24","25","26"]
		   optionResultArr = optionResultArr.map(Number);
		  if(harr.includes(data.project_name_index)){  //这是 700 到 10 注打底
		  	this.formData.result = JSON.parse(data.result)
		  }else if(arr.includes(data.project_name_index)){
		  	this.formData.numbers = data.numbers
			this.formData.result = JSON.parse(data.result)
		  }else if(optionResultArr.includes(data.project_name_index)){
			this.hundred = JSON.parse(data.record)
		  	this.formData.result = JSON.parse(data.result)
		  }else if(data.project_name_index == "29"){
			this.formData.result = JSON.parse(data.result)
			let arrstr = data.record.split("|")
			this.hundred =  JSON.parse(arrstr[0])
			this.ten = JSON.parse(arrstr[1]);
			this.theUnit = JSON.parse(arrstr[2]);
		  }
		   this.type = data.type
		   this.formData.lotteryNo = data.lotteryNo
			this.formData.projectNameIndex =  String(data.project_name_index);
			this.formData.lotteryTypeIndex =  data.lottery_type_index
			this.lottery = this.lotteryType[this.formData.lotteryTypeIndex];  
			let name =''
			this.projectNames.forEach(item =>{
				let a= item.projectName.filter(i => {
					return i.id==data.project_name_index
				})
				if(a.length!=0){
					name = a[0].name
				}
				
			})
			//this.projectName = name;
			this.selectProjectName(name,this.formData.projectNameIndex,data.commission)
		},
	  getData(){
		  this.$myRequest({
		    	method: 'get',
		    	url: '/getLastLotteryNo',
		    	data: {type:this.type}
		    }).then((res) => {
		  	  if(res.flag){
		  		   this.formData.lotteryNo = Number(res.data)+1
		  	  }
		  })
	  },
	  clearResult(){ // 当多选框按钮被修改时 清空数据
		  this.formData.result = "" 
	  },
	  clear() {
		 this.formData.result = "" 
	  },
	  paste() {
		  // 粘贴操作
		  uni.getClipboardData({
		  	success: (res) => {
		  		let clipboardContent = res.data;
		  	//	console.log('剪贴板内容:', clipboardContent);
		  
		  		// 使用正则表达式检查是否只包含数字和空格
		  		if (/^[0-9\s,]+$/.test(clipboardContent)) {
		  			// 如果剪贴板内容只包含数字，赋值给变量
		  			// 判断当前状态，如果已经有粘贴内容，进行拼接
					let max = this.textareaMaxlength/4
					let pasteCount = clipboardContent.trim().split(" ").length
					if(pasteCount>max){
						uni.showToast({
							title: '失败！您粘贴的注数超过最大的'+max+"注！",
							icon: 'none'
						});
						return
					} 
					let count = this.formData.result.trim().split(" ").length + pasteCount
					console.log("count"+count)
					if(count>=max){
						uni.showToast({
							title: '失败！您累计粘贴的注数超过最大的'+max+"注！",
							icon: 'none'
						});
						return
					}
		  			if (this.formData.result) {
		  				this.formData.result += ' ' + clipboardContent.trim()
		  			} else {
		  				this.formData.result = clipboardContent.trim(); // 第一次粘贴
		  			}
		  			uni.showToast({
		  				title: '粘贴成功',
		  				icon: 'none'
		  			});
		  		} else {
		  			uni.showToast({
		  				title: '粘贴失败，存在不法字符',
		  				icon: 'none'
		  			});
		  			// 这里可以添加提示用户的代码，比如弹窗、Toast等
		  		}
		  	},
		  	fail: (err) => {
		  		uni.showToast({
		  			title: '获取剪贴板内容失败',
		  			icon: 'none'
		  		});
		  	}
		  });
	  },
	  copyData(){
	  	const textToCopy = this.formData.result.join(' ');
	  	uni.setClipboardData({
	  		data: textToCopy,
	  		success: () => {
	  			uni.showToast({
	  				title: '复制成功',
	  				icon: 'success'
	  			});
	  		},
	  		fail: () => {
	  			uni.showToast({
	  				title: '复制失败',
	  				icon: 'none'
	  			});
	  		}
	  	});
	  },
	  getLastLotteryNo(){ // 获取最新期号
		  this.$myRequest({
		  	method: 'get',
		  	url: '/getLastLotteryNo',
		  	data: {type:this.type}
		  }).then((res) => {
			  if(res.flag){
				   this.formData.lotteryNo = Number(res.data)+1
			  }
		})
	  },
	  getLastLotteryResSunTail(){ // 排除3个和尾
				let arrbase = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];  
		  		 // 计算每对位数之间的差的绝对值
				let arrbaseResut =  arrbase.flatMap(i =>
							arrbase.flatMap(j =>   
							  arrbase.map(k => `${i}${j}${k}`)  
							)  
						  );  
				let resArr = this.formData.numbers.split("")
				resArr = resArr.map(Number);
				//let tail =	 Math.abs(Number(resArr[0]) + Number(resArr[1]) +  Number(resArr[2]))%10;;
				let result = arrbaseResut.filter(item => {
				   let item3SumTail = this.get3SumTail(item)
				   return !resArr.includes(item3SumTail)
				})		  
				return result
	  },
	  get3SumTail(number){ // 
			let  str =  number.toString();
		  return Math.abs(Number(str.charAt(0)) + Number(str.charAt(1))+ Number(str.charAt(2)))%10;
	  },
	  numberDiffer(index){ //21 22 23差计算
		//resArr = resArr.map(Number);
		let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];  
		let resArr = this.arrayDifference(arr,this.hundred)
		let resut =  arr.flatMap(i =>   
						arr.flatMap(j =>   
						  arr.map(k => `${i}${j}${k}`)  
						)  
					  );  
		let result = []
		//resut= resut.map(Number);
		switch(index){
			case "21": // 21 22 23百十计算
				//let dif = Math.abs( resArr[0]);
				result = resut.filter(item => {
					let num = item.split("")
					let difnum =Math.abs(Number(num[0])-  Number(num[1]));
					return !resArr.includes(difnum)
				})
				//this.textareaMaxlength =  result.join(" ").length
				break
			case "22": // 百个计算
				result = resut.filter(item => {
					let num = item.split("")
					let difnum =Math.abs(Number(num[0])-  Number(num[2]));
					return !resArr.includes(difnum)
				})
				break
			case "23": // 十个计算
				result = resut.filter(item => {
					let num = item.split("")
					let difnum =Math.abs(Number(num[1])-  Number(num[2]));
					return !resArr.includes(difnum)
				})
				break
				
			case "24": // 24 25 26 和计算
				let dif24 =Math.abs( resArr[0])%10;
				result =  resut.filter(item => {
					let num = item.split("")
					let difnum =Math.abs(Number(num[0]) + Number(num[1]))%10;
					return !resArr.includes(difnum)
				})
				break
			case "25": // 24 25 26 和计算
				let dif25 =Math.abs( resArr[0])%10;
				result =  resut.filter(item => {
					let num = item.split("")
					let difnum =Math.abs(Number(num[0]) + Number(num[2]))%10;
					return !resArr.includes(difnum)
				})
				break
			case "26": // 24 25 26 和计算
				let dif26 =Math.abs(  resArr[0])%10;
				result = resut.filter(item => {
					let num = item.split("")
					let difnum =Math.abs(Number(num[1]) + Number(num[2]))%10;
					return !resArr.includes(difnum)
				})
				break
			}
			return result
		},
	  openProjectName(){
		  this.$refs.alertDialog.open()
	  },
    selectProjectName(name,index,amount) { // 选择项目名称
		this.formData.projectNameIndex = index
		//this.formData.result = ""
		this.formData.commission = amount
		this.content = false
		this.resultContent = false
		this.numbers = false
		this. contentH = false
		this. contentT = false
		this. contentU = false
		this.optionButton = false
		this.pasteButton = false
		// this.hundred =  [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; 
		// this.ten = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; 
		// this.theUnit =  [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; 
		this.textareaMaxlength = 1000 *4
		switch(this.formData.projectNameIndex){
			case "1":
				this.textareaMaxlength = 700*4 + 99*4
				this.textareaMinlength = 700*4
				this.resultContent = true
				this.pasteButton = true
				break
			case "2":
				this.textareaMaxlength = 600*4 + 99*4
				this.textareaMinlength = 600*4
				this.resultContent = true
				this.pasteButton = true
				break
			case "3":
				this.textareaMaxlength = 500*4 + 99*4
				this.textareaMinlength = 500*4
				this.resultContent = true
				this.pasteButton = true
				break
			case "4":
				this.textareaMaxlength = 400*4 + 99*4
				this.textareaMinlength = 400*4
				this.resultContent = true
				this.pasteButton = true
				break
			case "5":
				this.textareaMaxlength = 300*4 + 99*4
				this.textareaMinlength = 300*4
				this.resultContent = true
				this.pasteButton = true
				break
			case "6":
				this.textareaMaxlength = 200*4 + 99*4
				this.textareaMinlength = 200*4
				this.resultContent = true
				this.pasteButton = true
				break
			case "7":
				this.textareaMaxlength = 100*4 + 99*4
				this.textareaMinlength = 100*4
				this.resultContent = true
				this.pasteButton = true
				break
			case "8":
				this.textareaMaxlength = 50*4
				this.textareaMinlength = 50*4
				this.resultContent = true
				this.pasteButton = true
				break
			case "9":
				this.textareaMaxlength = 10*4
				this.textareaMinlength = 10*4
				this.resultContent = true
				this.pasteButton = true
				break
			case "11":
				this.numLength = 5
				this.content = false
				this.numbers =  true
				this.resultContent = true
				break
			case "12":	
				this.numLength = 4
				this.content = false
				this.numbers =  true
				this.resultContent = true
				break
			case "13":	
				this.numLength = 3
				this.content = false
				this.numbers =  true
				this.resultContent = true
				break
			case "14": // 任意7码出23
				this.numLength = 7
				this.content = false
				this.numbers =  true
				this.resultContent = true
				break
			case "15":
				// this.content = true
				// this.numbers =  false
				// this. contentH = true
				this.numLength = 3
				this.content = false
				this.numbers =  true
				this.resultContent = true
				this.HTU = "百位："
				break
			case "16":
				 
				// this.numbers =  false
				// this. contentT = true
			//	this.HTU = "十位："
			this.numLength = 3
			this.content = false
			this.numbers =  true
			this.resultContent = true
				break
			case "17":
				// this.numbers =  false
				// this. contentU = true
			//	this.HTU = "个位："
			this.numLength = 3
			this.content = false
			this.numbers =  true
			this.resultContent = true
				break
			case "18": // 排除三个和尾
				//	this.getLastLotteryResSunTail()
				this.numLength = 3
				this.content = false
				this.numbers =  true
				this.resultContent = true
				// this.resultContent = true
				// this.numbers =  false
				break
			case "19": // 排除6个两码
				this.numLength = 17
				this.content = false
				this.numbers =  true
				this.resultContent = true
				break	
			case "20": // 排除任意两个号码
				// this.content = true
				// this.numbers =  false
				// this. contentH = true
				//this.HTU = "号码："
				this.numLength = 2
				this.content = false
				this.numbers =  true
				this.resultContent = true
				break
			case "21": // 21 22 23 差计算
				// this.hundred = [];
				// this.ten = [];
				// this.theUnit = [];
				this.content = true
				this. contentH = true
				//this. contentT = true
				//this. contentU = true
				this.HTU = "百十差："
				this.resultContent = true
				this.optionButton = true
				// this.getLastLotteryRes(index)
				// this.resultContent = true
				// this.numbers =  false
				break
			case "22":
				// this.getLastLotteryRes(index)
				// this.resultContent = true
				// this.numbers =  false
				// this.hundred = [];
				// this.ten = [];
				// this.theUnit = [];
				this.content = true
				this. contentH = true
				//this. contentT = true
				//this. contentU = true
				this.HTU = "百个差："
				this.resultContent = true
				this.optionButton = true
				break
			case "23":
				// this.getLastLotteryRes(index)
				// this.resultContent = true
				// this.numbers =  false
				// this.hundred =  [];
				// this.ten =  [];
				// this.theUnit =  [];
				this.content = true
				this. contentH = true
				//this. contentT = true
				//this. contentU = true
				this.HTU = "十个差："
				this.resultContent = true
				this.optionButton = true
				break
			case "24": // 24 25 26 和计算
				// this.getLastLotteryRes(index)
				// this.resultContent = true
				// this.numbers =  false
				// this.hundred = [];
				// this.ten = [];
				// this.theUnit = [];
				this.content = true
				this. contentH = true
				//this. contentT = true
				//this. contentU = true
				this.HTU = "百十和："
				this.resultContent = true
				this.optionButton = true
				break
			case "25":
				// this.hundred = [];
				// this.ten = [];
				// this.theUnit = [];
				this.content = true
				this. contentH = true
				//this. contentT = true
				//this. contentU = true
				this.HTU = "百个和："
				this.resultContent = true
				this.optionButton = true
				break
			case "26":
				// this.hundred = [];
				// this.ten = [];
				// this.theUnit = [];
				this.content = true
				this. contentH = true
				//this. contentT = true
				//this. contentU = true
				this.HTU = "十个和："
				this.resultContent = true
				this.optionButton = true
				break
			case "27": // 任意选3个差
				this.numLength = 3
				this.content = false
				this.numbers =  true
				this.resultContent = true
				break
			case "28": // 任意选3个和
				this.numLength = 3
				this.content = false
				this.numbers =  true
				this.resultContent = true
				break
			case "29": // 任意选3个和
				this.content = true
				this.numbers =  false
				this. contentH = true
				this. contentT = true
				this. contentU = true
				this.HTU = "百位："
				this.resultContent = true
				this.optionButton = true
				break
		}
		this.projectName = name;
		//this.formData.numbers = ""
		//this.$refs.alertDialog.close()
    },  
    selectLetteryType(event) {// 选择彩票种类的选项
		this.formData.lotteryTypeIndex = event.detail.value
		this.lottery = this.lotteryType[this.formData.lotteryTypeIndex];  
		if(this.formData.lotteryTypeIndex == 0){
			this.type = "plw"
		}else{
			this.type = "fcsd"
		}
    },  
    generateCombinations() {  
      const arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];  
      this.combinations1 = this.generateCombinationsForOneArray(this.checkbox, arr, arr);  
      this.combinations2 = this.generateCombinationsForOneArray(arr, this.checkbox1, arr);  
      this.combinations3 = this.generateCombinationsForOneArray(arr, arr, this.checkbox2);  
    },  
    generateCombinationsForOneArray(arr1, arr2, arr3) {  
      return arr1.flatMap(i =>   
        arr2.flatMap(j =>   
          arr3.map(k => `${i}${j}${k}`)  
        )  
      );  
    },
	checkItem6(item,num19){
		let a1 = num19[0].split("")
		let a2 = num19[1].split("")
		let a3 = num19[2].split("")
		let a4 = num19[3].split("")
		let a5 = num19[4].split("")
		let a6 = num19[5].split("")
		return this.checknum(item,a6)||this.checknum(item,a1)||this.checknum(item,a2)||this.checknum(item,a3)||this.checknum(item,a4)||this.checknum(item,a5)
	},
	checknum(item,arr){
		return item.includes(arr[0])&&item.includes(arr[1])
	},
	optionResult(){ // 计算结果
		let arr = ["11","12","13"] // 这是 5 4 3 码胆出选项
		let arr2728 = ["27","28"]  // 任意选3个和
		let result = [];
		if(arr.includes(this.formData.projectNameIndex)){
			let numberArray = this.formData.numbers.split("")
			if(numberArray.length <this.numLength){
				uni.showToast({
					title: '号码必须'+this.numLength+'位！'
				});
				return 
			}
			const arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; 
			let a1  = this.generateCombinationsForOneArray(numberArray, arr, arr);
			let a2 = this.generateCombinationsForOneArray(arr, numberArray, arr);  
			let a3 = this.generateCombinationsForOneArray(arr, arr, numberArray);  
			result = [...a1,...a2,...a3]
		}else if(this.formData.projectNameIndex == "14"){ // 7任意7码出2 3
			let numberArray = this.formData.numbers.split("")
			if(numberArray.length <this.numLength){
				uni.showToast({
					title: '号码必须'+this.numLength+'位！'
				});
				return 
			}
			const arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
			let a1  = this.generateCombinationsForOneArray(numberArray, numberArray, arr);
			let a2 = this.generateCombinationsForOneArray(arr, numberArray, numberArray);  
			let a3 = this.generateCombinationsForOneArray(numberArray, arr, numberArray);  
			result = [...a1,...a2,...a3]
		}else if(this.formData.projectNameIndex == "15"){  //百位排除3个号码
			if(this.formData.numbers.length != 3){
				uni.showToast({
					title: '号码必须3位号码！'
				});
				return
			}
			const arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
			let resArr = this.formData.numbers.split("")
			resArr = resArr.map(Number);
			let arrnew = this.arrayDifference(arr,resArr)
			result  = this.generateCombinationsForOneArray(arrnew, arr, arr);
		}else if(this.formData.projectNameIndex == "16"){  //十位排除3个号码
			if(this.formData.numbers.length != 3){
				uni.showToast({
					title: '号码必须3位号码！'
				});
				return
			}
			const arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
			let resArr = this.formData.numbers.split("")
			resArr = resArr.map(Number);
			let arrnew = this.arrayDifference(arr,resArr)
			result  = this.generateCombinationsForOneArray(arr, arrnew, arr);
		}else if(this.formData.projectNameIndex == "17"){  //个位排除3个号码
			if(this.formData.numbers.length != 3){
				uni.showToast({
					title: '号码必须3位号码！'
				});
				return
			}
			const arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
			let resArr = this.formData.numbers.split("")
			resArr = resArr.map(Number);
			let arrnew = this.arrayDifference(arr,resArr)
			result  = this.generateCombinationsForOneArray(arr, arr, arrnew);
		}else if(this.formData.projectNameIndex == "18"){  //排除三个和尾
			result = this.getLastLotteryResSunTail()
		}else if(this.formData.projectNameIndex == "19"){ // 排除6个两码
			let num19 = this.formData.numbers.split(" ")
			if(num19.length != 6){
				uni.showToast({
					title: '请输入6组号码每组中间用空格分隔！'
				});
				return
			}
			
			let arrbase = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
			let arrbaseResut =  arrbase.flatMap(i =>
							arrbase.flatMap(j =>   
							  arrbase.map(k => `${i}${j}${k}`)  
							)  
						  );  
			result = arrbaseResut.filter(item => {
			   return  !this.checkItem6(item,num19)
			})			  
			//this.formData.result = result.join(" ")
		}else if(this.formData.projectNameIndex == "20"){
			if(this.formData.numbers.length != 2){
				uni.showToast({
					title: '号码必须去掉2位！'
				});
				return
			}
			const arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
			let resArr = this.formData.numbers.split("")
			resArr = resArr.map(Number);
			let arrnew = this.arrayDifference(arr,resArr)
			result  = this.generateCombinationsForOneArray(arrnew, arrnew, arrnew);
		}else if(this.formData.projectNameIndex == "21"){ //百十
			if(this.hundred.length !=7 ){
				uni.showToast({
					title: '必须排除3个数！'
				});
				return
			}
			result = this.numberDiffer("21")
		}else if(this.formData.projectNameIndex == "22"){//百个
			if(this.hundred.length !=7 ){
				uni.showToast({
					title: '必须排除3个数！'
				});
				return
			}
			result = this.numberDiffer("22")
		}else if(this.formData.projectNameIndex == "23"){//十个
			if(this.hundred.length !=7 ){
				uni.showToast({
					title: '必须排除3个数！'
				});
				return
			}
			result = this.numberDiffer("23")
		}else if(this.formData.projectNameIndex == "24"){//十个
			if(this.hundred.length !=7 ){
				uni.showToast({
					title: '必须排除3个数！'
				});
				return
			}
			result = this.numberDiffer("24")
		}else if(this.formData.projectNameIndex == "25"){//十个
			if(this.hundred.length !=7 ){
				uni.showToast({
					title: '必须排除3个数！'
				});
				return
			}
			result = this.numberDiffer("25")
		}else if(this.formData.projectNameIndex == "26"){//十个
			if(this.hundred.length !=7 ){
				uni.showToast({
					title: '必须排除3个数！'
				});
				return
			}
			result = this.numberDiffer("26")
		}else if(arr2728.includes(this.formData.projectNameIndex)){
			if(this.formData.numbers.length != 3){
				uni.showToast({
					title: '号码必须3位号码！'
				});
				return
			}
			let arrbase = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
			let arrbaseResut =  arrbase.flatMap(i =>
							arrbase.flatMap(j =>   
							  arrbase.map(k => `${i}${j}${k}`)  
							)  
						  );  
			let optionNumbers =  this.formData.numbers.split("").map(Number);
			//  let itemSumOfDigitscc = this.sumOfDigitsAbsoluteValues("678")
			if(this.formData.projectNameIndex == "27"){ // 差
				result = arrbaseResut.filter(item => {
				   let itemCalculateDif = this.calculateDifferences(item)
				   return this.hasIntersection(itemCalculateDif,optionNumbers)
				})
			}else if(this.formData.projectNameIndex == "28"){ // 和
				result = arrbaseResut.filter(item => {
				   let itemSumOfDigits = this.sumOfDigitsAbsoluteValues(item)
				   return this.hasIntersection(itemSumOfDigits,optionNumbers)
				})
			}
		}else if(this.formData.projectNameIndex == "29"){
			if(this.hundred.length != 8){
				uni.showToast({
					title: '百位号码必须去掉2位！'
				});
					return 
			}
			if(this.ten.length != 8){
				uni.showToast({
					title: '十位号码必须去掉3位！'
				});
					return 
			}
			if(this.theUnit.length != 8){
				uni.showToast({
					title: '个位号码必须去掉3位！'
				});
					return 
			}
			result = this.generateCombinationsForOneArray(this.hundred, this.ten, this.theUnit);
		}
		 // 排序数组
		result.sort((a, b) => a - b);
		// 去重
		result = [...new Set(result)];
		this.formData.result = result.join(" ")
	},
	arrayDifference(arr1, arr2) { // 两个数组取非交集
	  const difference = arr1.filter(element => !arr2.includes(element));
	  return difference;
	},
	calculateDifferences(number) { //三位数差的绝对值
	  // 将3位数转换为字符串
	  const str = number.toString();
	  // 计算每对位数之间的差的绝对值
	  const diff1 = Math.abs(Number(str.charAt(0)) - Number(str.charAt(1)));
	  const diff2 = Math.abs(Number(str.charAt(1)) - Number(str.charAt(2)));
	  const diff3 = Math.abs(Number(str.charAt(0)) - Number(str.charAt(2)));
	  // 返回结果数组
	  return [diff1, diff2, diff3];
	},
	sumOfDigitsAbsoluteValues(number) { //三位数和的绝对值
	  // 将3位数转换为字符串
	  const str = number.toString();
	  // 计算每对位数之间的差的绝对值
	  const sum1 = Math.abs(Number(str.charAt(0)) + Number(str.charAt(1)))%10;
	  const sum2 = Math.abs(Number(str.charAt(1)) + Number(str.charAt(2)))%10;
	  const sum3 = Math.abs(Number(str.charAt(0)) + Number(str.charAt(2)))%10;
	  // 返回结果数组
	  return [sum1, sum2, sum3];
	},
	hasIntersection(arr1, arr2) { // 判断是否有交集
	  return arr1.filter(item => arr2.includes(item)).length > 0;
	},
	isArray7(arr) {
		return arr.length !== 7;
	},
    handleSubmit() { 
		let data  = JSON.parse(JSON.stringify(this.formData));
		let harr = ["1","2","3","4","5","6","7","8","9"] // 这是 700 到 10 注打底
		let arr = ["11","12","13","14","15","16","17","18","19","20","27","28"] // 这是 5 4 3 码胆出选项
		let optionResultArr = ["21","22","23","24","25","26","29"]
		if(harr.includes(this.formData.projectNameIndex)){  //这是 700 到 10 注打底
			if(this.formData.result.trim() == ""){
				uni.showToast({
					title: '号码必须填写！'
				});
				return 
			}
			if(this.formData.result.trim().split(" ").length < this.textareaMinlength/4){
				uni.showToast({
					title: '最少添加'+this.textareaMinlength/4+"组号码！"
				});
				return 
			}
			let arr  = this.formData.result.trim().split(" ")
			data.result = JSON.stringify(arr)
		}else if(arr.includes(this.formData.projectNameIndex)){
			if(this.formData.numbers.trim() == ""){
				uni.showToast({
					title: '号码必须填写！'
				});
				return 
			}
			if(this.formData.result.trim() == ""){
				uni.showToast({
					title: '请计算结果后再提交！'
				});
				return 
			}
			
			let arr  = this.formData.result.trim().split(" ")
			data.result = JSON.stringify(arr)
		}else if(optionResultArr.includes(this.formData.projectNameIndex)){
			if(this.formData.result.trim() == ""){
				uni.showToast({
					title: '请计算结果后再提交！'
				});
				return 
			}
			// if(this.hundred.length<2){
			// 	uni.showToast({
			// 		title: '请选择号码！'
			// 	});
			// 	return 
			// }
			let arr  = this.formData.result.trim().split(" ")
			const str = JSON.stringify(this.hundred)
			data.record = str
			data.result = JSON.stringify(arr)
		}else if(this.formData.projectNameIndex == "29"){
			let arr  = this.formData.result.trim().split(" ")
			data.result = JSON.stringify(arr)
			const str = JSON.stringify(this.hundred) + '|' + JSON.stringify(this.ten) +
				'|' + JSON.stringify(this.theUnit);
			data.record = str
		}
		 
		data.type = this.type
		
		this.$myRequest({
		  	method: 'post',
		  	url: '/submit',
		  	data: data
		  }).then((res) => {
			  console.log(res)
			  if(res.flag){
				 uni.showToast({
				 	title: '提交成功！'
				 });
			  }else{
				  uni.showToast({
				  	title: res.data
				  });
			  }
		})
     
    }  
  }  
};  
</script>  

<style>  
 .easyinputColor{
	 color: black !important;
 }
 .buttonActive01 {
 	/* border-radius: 100px; */
 	background-color: #742305;
 	/* 鼠标悬停时的背景颜色 */
 	color: white;
 }
 
 .buttonNoActive01 {
 	background-color: white;
 	/* width: 200rpx; */
 	/* border-radius: 10%; */
 }
 .row-conter{
	padding-top: 10px;
	display: flex;
	justify-content: center; /* 居中对齐 */
	align-items: center; /* 垂直居中对齐 */
 }
.demo-uni-row1 {
	width: 550px;
	margin-top: 30rpx;
	margin-top: 10px;
	display: flex; /* 使用 Flexbox 布局 */  
	flex-direction: row; /* 明确指定为横向排列，默认值即为 'row'*/  
	justify-content: flex-start; /* 可选：左对齐，其他选项可为 center, space-between, space-around 等 */  
	align-items: center; /* 可选：垂直居中对齐，适用于内容的高度不一致 */ 
}
.container {  
  height: 100vh;  
  padding: 20px;  
  background-color: #f6eee8;  
  border-radius: 10px;  
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1); 
}  
.picker-box { 
  border: 1px solid #ddd;  
  border-radius: 5px;  
  background-color: #fff;  
  padding: 10px;  
  transition: border-color 0.3s;  
}  
.scroll-container {  
  width: 100vw;   
 
}
.submit-button {  
  width: 70%;  
  height: 45px;  
  background-color: #742305;  
  color: white;  
  border: none;  
  border-radius: 5px;  
  font-size: 16px;  
  cursor: pointer;  
  transition: background-color 0.3s;  
}  
</style>